package ai.people.netmon.framework.domain.archives.dto;

import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * @author LiGuanNan
 * @date 2022/6/6 19:22
 */
@Data
@Builder
public class ThirdPartyCommonRespDTO<T> {

    /**
     * 请求成功时的代码值
     */
    private static List<Integer> successCodeValues = Lists.newArrayList(0, 200);

    /**
     * code
     */
    private Integer code;

    /**
     * mgs
     */
    private String msg;

    /**
     * 具体响应数据
     */
    private T data;

    public boolean isSuccess(){
        return successCodeValues.stream().anyMatch(o-> Objects.equals(o, code));
    }
    public static boolean isSuccess(Integer code){
        return successCodeValues.stream().anyMatch(o-> Objects.equals(o, code));
    }

}
